<template>
  <div>
    <el-dialog title="项目列表"
               :visible.sync="isShow"
               width="50%">
      <el-table :data="list" style="width: 100%">
        <el-table-column  align="center"  type="index"></el-table-column>
        <el-table-column  align="center" label="客户姓名" prop="customerName"></el-table-column>
        <el-table-column  align="center" label="负责人" prop="userName"></el-table-column>
        <el-table-column  align="center" label="项目名" prop="projectName"></el-table-column>
        <el-table-column  align="center" label="项目区域" prop="projectAreaName"></el-table-column>
        <el-table-column  align="center" label="项目来源" prop="projectSource"></el-table-column>
        <el-table-column  align="center" label="项目地址" prop="projectAddress"></el-table-column>
        <el-table-column align="center"  label="项目联系人" prop="receiverName"></el-table-column>
        <el-table-column  align="center" label="联系电话" prop="projectTel"></el-table-column>
          <el-table-column align="center" label="操作">
            <template slot-scope="scope">
              <el-button type="success" @click="Seact(scope.row)">选择</el-button>
            </template>
          </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>
<script>
import {ProjectList} from "@/api/module/project";
import {getDicts} from "@/api/system/dict/data";

export default {
  data(){
   return{
     isShow:false,
     list:[],
     projectSourceOptions:[],
   }
  },
  created(){
    this.initData()
    this.getProjectSourceOptions()
  },
  methods:{
    async initData(){
  let res=await ProjectList(this.form)
  // console.log(res)
      let arr=res.rows
      arr.forEach(item=>{
        item.projectSource=this.getValue(this.projectSourceOptions,item.projectSource)
      })
  this.list=arr
},
    getValue(arr, item) {
      for (let i = 0; i < arr.length; i++) {
        if (item === arr[i].dictValue) {
          return arr[i].dictLabel
        }
      }
    },
    // 获取项目信息来源
    getProjectSourceOptions() {
      getDicts('biz_project_source').then(response => {
        this.projectSourceOptions = response.data
      })
    },

    //选中数据
    Seact(val){
     this.isShow=false
     this.$emit('showProject',val)
    }
  }

}
</script>
